import { createRouter, createWebHistory } from "vue-router";
// 扩展 RouteMeta 类型
declare module "vue-router" {
    interface RouteMeta {
        title?: string;
    }
}
const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: "/",
            name: "home",
            meta: {
                title: "首页"
            },
            component: () => import("@/views/home.vue")
        },
        {
            path: "/test",
            name: "test",
            meta: {
                title: "测试页"
            },
            component: () => import("@/views/test.vue")
        }
    ]
});

router.beforeEach((to, from, next) => {
    document.title = to.meta.title || "默认标题";
    next();
});
export default router;
